package de.velvettear.squirrel.util;

import java.util.Vector;

import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import de.velvettear.squirrel.kernel.Contact;
import de.velvettear.squirrel.kernel.Statics;

public class MessageHelper {
			
	public static Message createMessage(String m_sType, String m_sValue1, String m_sValue2) {
		Log.i("createMessage()", "BEGIN");
		Bundle bundle = new Bundle();
		
		if (m_sType.equals(Statics.HANDLER_BRUTEFORCE)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_BRUTEFORCE + " CREATED");	
			bundle.putString(Statics.MESSAGE_BRUTEFORCE_PASSWORD, m_sValue1);
			bundle.putString(Statics.MESSAGE_BRUTEFORCE_COUNT, m_sValue2);
		} else if (m_sType.equals(Statics.HANDLER_SPLASH)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_SPLASH + " CREATED");	
			bundle.putString(Statics.MESSAGE_SPLASH, m_sValue1);
		} else if (m_sType.equals(Statics.HANDLER_PICTURE)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_PICTURE + " CREATED");
			bundle.putString(Statics.MESSAGE_PICTURE_PATH, m_sValue1);
			bundle.putString(Statics.MESSAGE_PICTURE_COMMAND, m_sValue2);
		} else if (m_sType.equals(Statics.HANDLER_GPS)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_GPS + " CREATED");
			bundle.putString(Statics.MESSAGE_GPS_LOCATION, m_sValue1);
			bundle.putString(Statics.MESSAGE_GPS_COMMAND, m_sValue2);
		} else if (m_sType.equals(Statics.HANDLER_DIALOG)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_DIALOG + " CREATED");
			bundle.putString(m_sValue1, m_sValue1);
			if (m_sValue2 != null) {
				bundle.putString(Statics.COMMAND_DIALOG_SPECIFIC, m_sValue2);
			}
		} else if (m_sType.equals(Statics.HANDLER_CHAT)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_CHAT + " CREATED");
			bundle.putString(m_sValue1, m_sValue2);
		} else if (m_sType.equals(Statics.HANDLER_SETTINGS)) {
			Log.i("createMessage()", "MESSAGE FOR " + Statics.HANDLER_SETTINGS + " CREATED");
			bundle.putString(m_sValue1, m_sValue2);
		}
				
		Message msg = Message.obtain();
		msg.setData(bundle);
	
		Log.i("createMessage()", "END");
		return msg;
	}
		
	public static Message createContactListMessage(Vector<Contact> contacts) {
		Log.i("createContactListMessage()", "BEGIN");
		
		Bundle bundle = new Bundle();
		bundle.putString(Statics.COMMAND_CHAT_CONTACTLIST, String.valueOf(contacts.size()));
		
		int counter = 0;
		for (Contact contact : contacts) {
			bundle.putSerializable(String.valueOf(counter), contact);
			counter++;
		}
			
		Message msg = Message.obtain();
		msg.setData(bundle);
		
		Log.i("createContactListMessage()", "END");
		return msg;
	}
	
	public static Message createPresenceMessage(String name, String status, String mode, String type) {
		Log.i("createPresenceMessage()", "BEGIN");
		
		Bundle bundle = new Bundle();
		bundle.putString(Statics.COMMAND_CHAT_PRESENCE, Statics.COMMAND_CHAT_PRESENCE);
		bundle.putString("name", name);
		bundle.putString("status", status);
		bundle.putString("mode", mode);
		bundle.putString("type", type);
		
		Message msg = Message.obtain();
		msg.setData(bundle);
		
		Log.i("createPresenceMessage()", "END");
		return msg;
	}
	
}
